package net.jcip.vehicles;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class MonitorVehicleTrackerPublishing {
	private final ConcurrentMap<String, PublishPoint> locations;
	private final Map<String, PublishPoint> unmodifiableMap;
	
	public MonitorVehicleTrackerPublishing(Map<String,PublishPoint> data){
		
		locations = new ConcurrentHashMap<String,PublishPoint>(data);
		unmodifiableMap = Collections.unmodifiableMap(locations);
	}
	
	
	public PublishPoint getLocation(String name){
		return locations.get(name);
	}
	
	public void setLocation( String name, int x, int y) {
		if (!locations.containsKey(name)){
			throw new IllegalArgumentException();
		}
		locations.get(name).set(x, y);
	}
	
	public Map<String, PublishPoint> getLocations(){
		return unmodifiableMap;
	}
}
